package io.renren.modules.cs.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.cs.entity.ZbEntity;
import io.renren.modules.cs.service.ZbService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author zj
 * @email 465189260@qq.com
 * @date 2020-08-17 14:29:41
 */
@RestController
@RequestMapping("cs/zb")
public class ZbController {
    @Autowired
    private ZbService zbService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("cs:zb:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = zbService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("cs:zb:info")
    public R info(@PathVariable("id") Long id){
        ZbEntity zb = zbService.getById(id);

        return R.ok().put("zb", zb);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cs:zb:save")
    public R save(@RequestBody ZbEntity zb){
        zbService.save(zb);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cs:zb:update")
    public R update(@RequestBody ZbEntity zb){
        ValidatorUtils.validateEntity(zb);
        zbService.updateById(zb);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cs:zb:delete")
    public R delete(@RequestBody Long[] ids){
        zbService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
